﻿using System;
using Shapes;

namespace ShapesProgram
{
    class Program
    {
        static void Main(string[] args)
        {
            //用户选择想要创建的类
            while(true)
            {
                Console.WriteLine("请选择你要创建的图形类:\n 1代表长方形\n 2代表正方形\n 3代表三角形\n 4表示退出程序");
                string str = Console.ReadLine();
                int num=int.Parse(str);
                switch(num)
                {
                    case 1:
                        Console.WriteLine("请输入两个数表示长方形的长与宽，用空格相隔：");
                        string str1 = Console.ReadLine();
                        string []strArr1=str1.Split(' ');
                        Rectangle rectangle = new Rectangle(double.Parse(strArr1[0]), double.Parse(strArr1[1]));
                        if (rectangle.IsShapeValid())
                            Console.WriteLine($"长方形的面积: {rectangle.CalculateArea()}");
                        else Console.WriteLine("形状参数不合理");
                        break;

                    case 2:
                        Console.WriteLine("请输入一个数表示正方形的边长：");
                        string str2 = Console.ReadLine();
                        Square square = new Square(double.Parse(str2));
                        if (square.IsShapeValid())
                            Console.WriteLine($"正方形的面积: {square.CalculateArea()}");
                        else Console.WriteLine("形状参数不合理");
                        break;
                    case 3:
                        Console.WriteLine("请输入三个数表示三角形的三条边，用空格相隔：");
                        string str3 = Console.ReadLine();
                        string[] strArr3 = str3.Split(' ');
                        Triangle triangle = new Triangle(double.Parse(strArr3[0]), double.Parse(strArr3[1]),double.Parse(strArr3[2]));
                        if (triangle.IsShapeValid())
                            Console.WriteLine($"三方形的面积: {triangle.CalculateArea()}");
                        else Console.WriteLine("形状参数不合理");
                        break;

                    case 4:
                        num -= 4;
                        break;
                }
                if (num==0) break;
            }
           
        }
    }
}